package io.ken.im.common.domain.enums;

/**
 * @author: ken
 * @description:
 * @date 2023-12-11
 **/
public enum IMCmdType {

    LOGIN(0, "login"),
    HEART_BEAT(1, "heartbeat"),
    FORCE_LOGOUT(2, "force logout"),
    PRIVATE_MESSAGE(3, "private message"),
    GROUP_MESSAGE(4, "group message");

    private final Integer code;
    private final String desc;

    IMCmdType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static IMCmdType fromCode(Integer code) {
        for (IMCmdType typeEnum : values()) {
            if (typeEnum.code.equals(code)) {
                return typeEnum;
            }
        }
        return null;
    }


    public Integer code() {
        return this.code;
    }
}
